import { QueryPageDto } from './dto'
import request from './request'

// 获取已成交客户
export function getPublicClient (data: {
    search: string
}): Promise<{ name: string; create_time: string }[]> {
    return request.get('/client/publicSearch', data)
}

// 获取客户列表
interface getClientDto extends QueryPageDto {
    isActive: 0 | 1 // 0 未投保客户    1 已投保客户
    sort: string // 排序字段 createtime开户时间 balance余额 person在保人数
    order: string // 'desc' | 'asc'
}
export interface ClientDto {
    client_id: number
    active_num: number
    balance: number
    create_time: string
    name: string
}
export function getClient (
    data: getClientDto
): Promise<{ data: ClientDto[]; total: number }> {
    return request.get('/client/list', data)
}

// 获取客户详情
export interface ClientDetailDto {
    name: string
    balance: number
    active_num: number
    real_name: string
    mobile: string
}
export function getClientDetail (data: {
    clientId: string
}): Promise<ClientDetailDto> {
    return request.get('/client/detail', data)
}

// 获取加减保记录
interface getClientOrderDto extends QueryPageDto {
    clientId: string
}
export interface ClientOrderDto {
    type: string
    start_date: string
    person_count: number
}
export function getClientOrder (
    data: getClientOrderDto
): Promise<{ total: number; data: ClientOrderDto[] }> {
    return request.get('/order/list', data)
}
